<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-store">
    <meta http-equiv="Cache-Control" content="no-cache,no-store">
    <meta http-equiv="expires" content="0">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>奖品列表</title>
    <link rel="stylesheet" href="./css/modal-px.css" media="screen" title="no_title" charset="utf-8"/>
    <style media="screen" title="no_title">@charset "UTF-8";.clear:after{content:'';display:block;clear:both;width:0;height:0}*{margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,255,255,0);font-family:PingFang SC,STHeiti,"Microsoft Yahei","微软雅黑",Helvetica,sans-serif;-webkit-touch-callout:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;outline:0}a:active,a:hover,a:link,a:visited{text-decoration:none;outline:0}ul,li{list-style:none}html,body{width:100%;min-height:100%;padding:0;background:#fff;overflow:scroll;-webkit-overflow-scrolling:touch;position:relative}.forbid{height:100vh!important;overflow:hidden!important}input{border:1px solid #ddd;-webkit-appearance:none;padding:0 8px;font-size:14px}.hidden{width:0;height:0;opacity:0;overflow:hidden}.main{width:100vw;min-height:100%;overflow:scroll;-webkit-overflow-scrolling:touch;background:#fff}.main ul{padding:.45rem}.main ul li{background-color:#f6f6f6;padding:.4rem;margin-bottom:.45rem;-webkit-box-orient:horizontal;-ms-box-orient:horizontal;-moz-box-orient:horizontal;-webkit-flex-flow:row nowrap;-ms-flex-flow:row nowrap;-moz-flex-flow:row nowrap;flex-flow:row nowrap;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-justify-content:center;-webkit-justify-content:center;justify-content:center;-ms-justify:center;-webkit-justify:center;justify:center;-ms-box-align:center;-webkit-box-align:center;box-align:center;-ms-align-items:center;-webkit-align-items:center;align-items:center}.main ul li:last-child{margin-bottom:0}.main ul li img{display:block;width:2.9rem;height:2.9rem;margin-right:.4rem}.main ul li .center{-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-size:.65rem;-webkit-box-orient:vertical;-ms-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-flow:column nowrap;-ms-flex-flow:column nowrap;-moz-flex-flow:column nowrap;flex-flow:column nowrap;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;margin-right:.25rem;align-self:flex-start}.main ul li .center .name{font-size:.7rem;line-height:.9rem;color:#000;font-weight:500;-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.main ul li .center .sponsor{font-size:.6rem;line-height:.85rem;margin-top:.25rem}.main ul li .button{width:3rem;height:1.2rem;line-height:1.2rem;display:block;background:#fb3131;color:#fff;font-size:.7rem;text-align:center;font-weight:500;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.main ul li .button.disabled{background:#d4d4d4}.bombBox{width:100vw;height:100vh;position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.4);padding:0 1.75rem;display:none;z-index:100}.bombBox.show{display:block}.bombBox:after{content:'';display:block;clear:both;width:0;height:0}.bombBox .close{width:1.05rem;height:3.425rem;background:url(./img/red-close.png) no-repeat bottom center;background-size:100% auto;margin-bottom:1.25rem;float:right}.bombBox .boxContent{width:100%;background:#fff;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem;float:right;padding:0 .975rem 1.35rem}.bombBox .boxContent h3{text-align:center;font-size:.8rem;font-weight:500;padding:.6rem 0}.bombBox .boxContent button{width:6.95rem;height:1.55rem;line-height:1.55rem;outline:0;display:block;background:#fb3131;color:#fff;font-size:.7rem;text-align:center;font-weight:500;margin:1.5rem auto 0;border:0;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox .boxContent form input{display:block;font-size:.65rem;width:100%;height:1.55rem;margin-top:.6rem;padding:0 .5rem;outline:0;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox.success .boxContent{height:12.5rem;background:url(./img/success-bg.png) no-repeat center;background-size:100% 100%}.bombBox.success .boxContent .prizeName{text-align:center;font-size:.7rem;color:#fff;margin-top:3rem}.bombBox.success .boxContent .imgs{margin-top:.85rem}.bombBox.success .boxContent .prizeImg{width:3rem;height:3rem;display:block;margin:0 auto;background-color:#fff;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox.success .boxContent .sponsorImg{width:3rem;height:1.25rem;display:block;margin:0 auto;background-color:#fff;margin-top:.25rem}.bombBox.success .boxContent button{margin-top:.6rem}.bombBox.fail .boxContent{height:12.5rem;background:url(./img/fail-bg.png) no-repeat center;background-size:100% 100%}.bombBox.fail .boxContent button{margin-top:9rem}</style>
</head>
<body style="visibility: hidden;">
<div class="main" id="main">
    <ul id="prizes">
        <!--<li>-->
            <!--<img src="/images/001.png" alt=""/>-->
            <!--<div class="center">-->
                <!--<div class="name">漫步者多媒体音箱漫步者多媒体音箱</div>-->
                <!--<div class="sponsor">漫步者赞助</div>-->
            <!--</div>-->
            <!--<a class="button">领取</a>-->
        <!--</li>-->
    </ul>
</div>
<script type="text/template" id="prizes-template">
    {{each list as item i}}
    <li>
        <img src="{{item.prize.background_image}}" alt=""/>
        <div class="center">
            <div class="name">{{item.prize.name}}</div>
            {{if item.prize.type_code=='coupon'}}
            <div class="sponsor">兑换码：{{item.coupon}}</div>
            {{/if}}
            {{if item.prize.type_code=='entity'&&item.is_exchange==1&&item.logistics}}
            <div class="sponsor">物流公司：{{item.logistics.company.name}}</div>
            <div class="sponsor">运单单号：{{item.logistics.order_number}}</div>
            {{/if}}
            {{if item.prize.sponsor.name}}
            <div class="sponsor">赞助商:{{item.prize.sponsor.name}}</div>
            {{/if}}
        </div>
        {{if item.prize.type_code=='coupon'&&item.is_exchange==0}}
        <a class="button coupon" url="{{item.prize.exchange_url}}">兑换</a>
        {{/if}}
        {{if item.prize.type_code=='coupon'&&item.is_exchange==1}}
        <a class="button coupon disabled" url="{{item.prize.exchange_url}}">已兑换</a>
        {{/if}}
        {{if item.prize.type_code=='entity'&&item.is_confirm==0}}
        <a class="button" name="{{item.prize_id}}">领取</a>
        {{/if}}
        {{if item.prize.type_code=='entity'&&item.is_confirm==1&&item.is_exchange==0}}
        <a class="button disabled" name="{{item.prize_id}}">发放中</a>
        {{/if}}
        {{if item.prize.type_code=='entity'&&item.is_confirm==1&&item.is_exchange==1}}
        <a class="button disabled" name="{{item.prize_id}}">已发放</a>
        {{/if}}
    </li>
    {{/each}}
</script>
<script type="text/javascript">
    (function (doc, win) {

        var docEl = doc.documentElement,
            resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
            recalc = function () {
                var clientWidth = docEl.clientWidth;
                if (!clientWidth) return;
                // 针对uc横竖屏rem html没有重绘的问题
                var style;
                if (style = document.getElementById("forhtml")) {
                    style.parentNode.removeChild(style);
                }
                style = document.createElement("style");
                style.id = "forhtml";
                document.head.appendChild(style);
                style.appendChild(document.createTextNode("html{font-size:" + 20 * (clientWidth / 320) + "px !important;}"));
            };
        recalc();
        document.body.style.visibility = 'visible';
        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
        var a = document.getElementsByTagName('a');
        for (var i = 0; i < a.length; i++) {
            a[i].addEventListener('touchstart', function () {
            }, false);
        }
    })(document, window);
</script>
<script type="text/javascript" src="./lib/zepto.min.js"></script>
<script type="text/javascript" charset="utf-8" src="./lib/zepto-adapter.js"></script>
<script type="text/javascript" charset="utf-8" src="./lib/template.min.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/modal.js"></script>
<script type="text/javascript" src="./js/utils.js"></script>
<script type="text/javascript" src="./js/bombBox.js?_=2018e3f4f421"></script>
<script type="text/javascript">
    window.isPrizes = true;
    $(document).ready(function() {
        var prize = {},list=[],$thisbtn,index=0;
        function openAddress(prize,$thisbtn){
            var $addressModal = new Modal({
                prize: prize,
                yesCallback: function(){
                    $('ul').removeClass('forbid');
                    $thisbtn.addClass('disabled').text('发放中');
                },
                closeCallback: function(){
                    $('ul').removeClass('forbid');
                }
            },'address');
            $addressModal.open();
        }
        function openFillInfo(prize,$thisbtn){
            var $fillInfoModal = new Modal({
                prize: prize,
                yesCallback: function(){
                    $('ul').removeClass('forbid');
                    $thisbtn.addClass('disabled').text('已兑换');
                },
                closeCallback: function(){
                    $('ul').removeClass('forbid');
                }
            },'fillInfo');
            $fillInfoModal.open();
        }
        function openConvert(prize,$thisbtn){
            var $convertModal = new Modal({
                prize: prize,
                yesCallback: function(){
                    location.href = prize.prize.exchange_url;
                },
                closeCallback: function(){
                    $('ul').removeClass('forbid');
                }
            },'convert');
            $convertModal.open();
        }
        function render(){
            requestWinners(false,function(data){
                $('#prizes').html(template('prizes-template',{list:data.data}));
                list = data.data;
                if(data.data.length==0){
                    $('#main').prepend('<p style="text-align:center;font-size:.7rem;color:#000;padding:.8rem;">暂还没有中奖纪录，赶紧加油哦！</p>');
                }
                $('.button').on('click',function(e){
                    $thisbtn = $(this);
                    index = $(this).parents('li').index();
                    prize = list[index];
                    if(!$thisbtn.hasClass('disabled')){
                        $('ul').addClass('forbid');
                        if(!$(this).hasClass('coupon')){
                            openAddress(prize,$thisbtn);
                        }else{
                            if(prize.prize['exchange_method']=='0'){
                                openConvert(prize,$thisbtn);
                            }else{
                                openFillInfo(prize,$thisbtn);
                            }
                        }
                    }
                });
            });
        }
        //验签
        // -2:不在app内  -1：没登录  0：验签失败  1：验签成功
        var isSignPass = -2;
        function signCallBack() {
            if(window.parameter.mfSign){
                if(window.parameter.userid || window.parameter.uid){
                    $.ajax({
                        url: '/api/app/sign/mf.php',
                        data:window.parameter,
                        type: 'get',
                        success: function(ajaxData) {
                            if (ajaxData.code == 200) {
                                isSignPass = 1;
                                render();
                            } else {
                                alert('验签失败!');
                                isSignPass = 0;
                            }
                        },
                        error: function(){
                            alert('网络异常！');
                            isSignPass = 0;
                        }
                    });
                }else{
                    isSignPass = -1;
                }
            }else{
                isSignPass = -2;
            }
        }
        if(window.parameter['ways']!='wechat'){
            signCallBack();
        }else{
            isSignPass = 1;
            render();
        }
    });
</script>
</body>
</html>